<template>
  <div>
    <span class="f_16 f_bold marginB10">我的资产</span>
    <div class="inlineBlock pullRight">
      <Button type="primary" class="marginB10" @click="wrcW">
        <i class="iconfont iconshoppingcopy relative" style="top:1px;"></i>
        购 买
      </Button>
    </div>
    <div class="clearBoth"></div>

    <div v-show="vwrShow" class="f_16">
      <Table stripe border :columns="columns1" :data="data1"></Table>
    </div>

    <div class="clearBoth"></div>

    <!-- 增值套餐 购买 -->
    <TaoCan ref="TaoCan" @huoDci="huoDci" />

  </div>
</template>

<script>
import TaoCan from "@$@/_service/taoCan"; // 套餐支付
export default {
  name: "accZc",
  props: ["userPower", "companyAll"],
  components: {TaoCan},
  data() {
    let data = {
      role_service_item_list: {
        tm_search: {}, //商标查询
        patent_search: {} //专利查询
      }, //免费套餐
      service_item_list: {}, //已经购买了年费的套餐
      columns1: [],
      data1: []
    };
    let tool = {
      vwrShow: false
    };
    return Object.assign(data, tool);
  },
  created() {
    this.huoDci();
  },
  mounted() {
    let {
      $route:{
        query:{
          TC_type
        }
      }
    }=this;

    // 地址栏上，有这个参数，证明是在搜索页，用完了今天的数量，强制跳过来的。
    // 有这个参数，会强制跳出，充值框
    ($app.judgeData(TC_type)) && (this.$refs["TaoCan"].showBox = true);
  },
  methods: {
    wrcW(){
      this.$refs["TaoCan"].showBox = true;
    },
    huoDci(){
      $ajax.wZcList(({ role_service_item_list, service_item_list }) => {
        this.vwrShow = true;
        this.role_service_item_list = role_service_item_list;
        this.service_item_list = service_item_list;

        this.columns1=[
          {
            type: 'index',
            title:'序号',
            align: "center",
            width:70,
          },
          {
            title: "名称",
            key: "name",
            width:200
          },
          {
            title: "购买时间",
            key: "created_at"
          },
          {
            title: "到期时间",
            key: "end_at"
          },
          {
            title: "数量",
            key: "shuL"
          }
        ];
        this.data1=[
          {
            name: "商标检索",
            created_at: (service_item_list.tm_search)?service_item_list.tm_search.created_at:'未购买',
            end_at: (service_item_list.tm_search)?service_item_list.tm_search.end_time:'未购买',
            shuL: (service_item_list.tm_search)?'不限':('已使用：'+role_service_item_list.tm_search.used_num + "/" + role_service_item_list.tm_search.num + " 次")
          },
          {
            name: "专利检索",
            created_at: (service_item_list.patent_search)?service_item_list.patent_search.created_at:'未购买',
            end_at: (service_item_list.patent_search)?service_item_list.patent_search.end_time:'未购买',
            shuL: (service_item_list.patent_search)?'不限':'未购买'
          },
          {
            name: "商标管理",
            created_at: (service_item_list.tm_manage)?service_item_list.tm_manage.created_at:'未购买',
            end_at: (service_item_list.tm_manage)?service_item_list.tm_manage.end_time:'未购买',
            shuL: (service_item_list.tm_manage)?('已管理：'+service_item_list.tm_manage.used_num + "/" +service_item_list.tm_manage.num+' 笔'):'未购买'
          },
          {
            name: "专利管理",
            created_at: (service_item_list.patent_manage)?service_item_list.patent_manage.created_at:'未购买',
            end_at: (service_item_list.patent_manage)?service_item_list.patent_manage.end_time:'未购买',
            shuL: (service_item_list.patent_manage)?('已管理：'+service_item_list.patent_manage.used_num + "/" +service_item_list.patent_manage.num+' 笔'):'未购买'
          },
          {
            name: "商标分析报告",
            created_at: (service_item_list.tm_report)?service_item_list.tm_report.created_at:'未购买',
            end_at: (service_item_list.tm_report)?service_item_list.tm_report.end_time:'未购买',
            shuL: (service_item_list.tm_report)?('已使用：'+service_item_list.tm_report.used_num + "/" +service_item_list.tm_report.num+' 份'):'未购买'
          },
          {
            name: "客户线索",
            created_at: (service_item_list.tm_clue)?service_item_list.tm_clue.created_at:'未购买',
            end_at:(service_item_list.tm_clue)?service_item_list.tm_clue.end_time:'未购买',
            shuL: (service_item_list.tm_clue)?('已申请：'+service_item_list.tm_clue.used_num + "/" +service_item_list.tm_clue.num+' 条'):'未购买'
          },
          // {
          //   name: "专利查重",
          //   created_at: '正在开发中',
          //   end_at:'正在开发中',
          //   shuL:'正在开发中'
          // }
        ];

      });
    }
  }
};
</script>

